package com.CST.controller.ys;

import com.CST.common.api.ResultObject;
import com.CST.common.constant.Constants;
import com.CST.dto.ys.BudgetDTO;
import com.CST.dto.ys.ExportDTO;
import com.CST.entity.cb.BdSysUser;
import com.CST.mapper.cst.ys.YsAccountBudgetMapper;
import com.CST.service.ys.YsAccountBudgetService;
import com.CST.util.HttpUtil;
import com.CST.vo.ys.BudgetRelease;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/release")
@Api(tags = "预算下达数据")
public class YsAccountBudgetController {

    private final YsAccountBudgetService service;
    @Autowired
    private YsAccountBudgetMapper mapper;
    public YsAccountBudgetController(YsAccountBudgetService service) {
        this.service = service;
    }

    @PostMapping("/budget")
    @ApiOperation("查询预算下达数据")
    private ResultObject<BudgetRelease> business(@RequestBody BudgetDTO dto){
        if(dto.getType().equals(1)){
            return ResultObject.success(service.business(dto));
        }else{
            return ResultObject.success(service.management(dto));
        }
    }

    @PostMapping("/download1")
    @ApiOperation("导出预算下达")
    public void exportExcel1(@RequestBody ExportDTO dto, HttpServletResponse response) throws IOException {
        if(dto.getType().equals(1)){
            service.exportExcel1(dto,response);
        }else{
            service.exportExcel2(dto,response);
        }
    }

    @PostMapping("/download")
    @ApiOperation("导出模板")
    public void exportExcel3( HttpServletResponse response){
        service.exportExcel3(response);
    }



}
